import requests

# url = 'https://www.bilibili.com/'
url = 'https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd?web_location=1430650&y_num=4&fresh_type=3&feed_version=V8&fresh_idx_1h=3&fetch_row=1&fresh_idx=3&brush=2&device=win&homepage_ver=1&ps=10&last_y_num=4&screen=891-730&seo_info=&tt_exp=&last_showlist=av_115422179361494,av_115444778272366,av_115451422052438,ad_5614,av_n_115451522782505,av_n_115422380755036,av_n_115428101915051,av_n_115439761884210,av_n_115451187173251,av_n_115428722481731%3Blogin_card_undefined,av_115450801295127,av_115435399809730,av_115456723650137,av_n_115444912492615,av_115433201996436,av_115450063095288,av_n_115445935902845,av_n_115451656933151,av_n_115456589432003%3Bav_115435265728461,av_115428739252655,av_115421491494936,ad_5614,av_n_115450264424578,av_n_115445415873649,av_n_115456690100238,av_n_115450717405556,av_n_115443805196356,av_n_115439443117431&uniq_id=1481891598251&w_rid=37340c485121db50c91053ba02976fde&wts=1761790503'
headers = {
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36'
}


# res = requests.get(url,headers=headers)
# print(res.status_code)
# # print()
# res_text = res.json()['data']
# print(len(res_text))
# print(res_text)
# for item in res_text['item']:
#     print(item.get('title'))
#     print(item.get('pic'))

index_url = 'https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd?web_location=1430650&y_num=3&fresh_type=4&feed_version=V8&fresh_idx_1h=1&fetch_row=4&fresh_idx=1&brush=1&device=win&homepage_ver=1&ps=12&last_y_num=4&screen=934-730&seo_info=&tt_exp=&last_showlist=av_115441037088226,av_n_115424544954269,av_115457663239666,ad_n_5614_115446875426016,av_115430450534433,av_115450180602981,av_115420484867379,av_n_115456975574826,av_n_115440047096351,av_n_115428722545851&uniq_id=322804499252&w_rid=512fc180fc20fe99d353fbe94d0d6e21&wts=1761791422'

response = requests.get(index_url,headers=headers)
print(response.status_code)
# print(response.json()['data'])
datas = response.json()['data']
print(len(datas))